#ifndef SNAKE_H
#define SNAKE_H

#include <QWidget>
#include <QDebug>
#include <QPainter>
#include <QRandomGenerator>
#include <QKeyEvent>
#include <QTimerEvent>
#include <QList>
#include <QPoint>
#include <QDateTime>
#include <QMessageBox>
#include <QPushButton>
#include <QPixmap>
#include <QLabel>
#include <QSet>

enum dir
{
    Up,//上
    Down,//下
    Left,//左
    Right//右
};


namespace Ui {
class snake;
}

class snake : public QWidget
{
    Q_OBJECT

public:
    explicit snake(QWidget *parent = nullptr);
    ~snake();

public:
        virtual void  paintEvent(QPaintEvent *event);

        virtual void keyPressEvent(QKeyEvent *event);
        virtual void keyReleaseEvent(QKeyEvent *event);

        void timerEvent(QTimerEvent *e);

        QList<QPoint> food;
        QList<QPoint> snakelist;
        QList<QPoint> fence;
        //蛇头出生点随机数
        int snakerow;//行
        int snakeclo;//列
        dir snakedir;//方向
        int cellsize;//小格子边长
        int  id;
        int grade;
        int life;
    public:
        void  resetTimer(int mill);

        void  eat_food();
        void  eat_fence();
        // void remove(QPoint point);//删除唯一坐标集中的指定坐标


    private slots:
        void on_comboBox_currentTextChanged(const QString &arg1);

    private:
    Ui::snake *ui;
};

#endif // SNAKE_H
